package tree;

/**
 * @author kaho
 * @since 2021/3/2
 */
public class _226_翻转二叉树 {

    /**
     * 翻转一棵二叉树。
     * @param root
     * @return
     */
    public TreeNode invertTree(TreeNode root) {
        if (root ==null) {
            return null;
        }
        invertTree(root.left);
        invertTree(root.right);
        TreeNode left = root.left;
        root.left = root.right;
        root.right = left;
        return root;
    }
}
